import Vue from 'vue'

import App from './App'
// import router from './router'
import store from '../../store'
import MyStorage from '../../plugins/MyStorage'

Vue.use(MyStorage)

if (!process.env.IS_WEB) Vue.use(require('vue-electron'))
Vue.config.productionTip = false

// window.addEventListener('storage', (ev) => {
//   if (ev.key !== 'communication') return
//   let arg = myStorage.getItem('communication', {})
//   let win = Vue.prototype.$electron.remote.getCurrentWindow()
//   switch (arg.action) {
//     case 'showInfoWindow':
//       store.commit('setCurrentIp', arg.data.data)
//       if (router.currentRoute.path !== arg.data.config.router) router.push(arg.data.config.router)
//       win.setPosition(arg.data.config.x, arg.data.config.y)
//       win.setResizable(true)
//       win.setSize(arg.data.config.width, arg.data.config.height)
//       win.setResizable(false)
//       win.show()
//       break
//     case 'showInfoMiniWindow':
//       if (win.isVisible()) return
//       store.commit('setCurrentIp', arg.data.data)
//       if (router.currentRoute.path !== arg.data.config.router) router.push(arg.data.config.router)
//       // let win = Vue.prototype.$electron.remote.getCurrentWindow()
//       win.setPosition(arg.data.config.x, arg.data.config.y)
//       win.setResizable(true)
//       win.setSize(arg.data.config.width, arg.data.config.height)
//       win.setResizable(false)
//       win.show()
//       break
//     case 'hideInfoWindow':
//       Vue.prototype.$electron.remote.getCurrentWindow().close()
//       break
//     case 'hideInfoMiniWindow':
//       if (router.currentRoute.path === '/infoboxmini') Vue.prototype.$electron.remote.getCurrentWindow().close()
//       break
//   }
// })

Vue.prototype.$electron.ipcRenderer.on('hideSetWindow', () => {
  store.dispatch('setSetWindowShow', false)
})

/* eslint-disable no-new */
new Vue({
  components: {App},
  // router,
  store,
  template: '<App/>'
}).$mount('#app')
